package MaxInterface;

import com.dukascopy.api.IAccount;
import com.dukascopy.api.IBar;
import com.dukascopy.api.IConsole;
import com.dukascopy.api.IContext;
import com.dukascopy.api.IEngine;
import com.dukascopy.api.IHistory;
import com.dukascopy.api.IIndicators;
import com.dukascopy.api.IMessage;
import com.dukascopy.api.IOrder;
import com.dukascopy.api.IStrategy;
import com.dukascopy.api.ITick;
import com.dukascopy.api.Instrument;
import com.dukascopy.api.JFException;
import com.dukascopy.api.Library;
import com.dukascopy.api.Period;
import com.dukascopy.api.RequiresFullAccess;

@RequiresFullAccess
@Library("C:/Users/Barbos/Eclipse/nimy_java/JForex/src/MaxInterface/libs/dashboard.jar")

public class temptestStrategy implements IStrategy{
	
	//��������� ����������
	private IIndicators indicators = null;
    private IConsole console;
    private IEngine engine = null;
    private IOrder order = null;
    private IHistory history;
    private IAccount account = null;
	private DashboardSignal signal = null;
    private Period globalPeriod = Period.FIVE_MINS;
    
	@Override
	public void onStart(IContext context) throws JFException {
		// TODO Auto-generated method stub
		engine = context.getEngine();
        indicators = context.getIndicators();
        this.console = context.getConsole();
        this.history = context.getHistory();
        this.account = context.getAccount();
        
    }

	@Override
	public void onTick(Instrument instrument, ITick tick) throws JFException {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void onBar(Instrument instrument, Period period, IBar askBar,
			IBar bidBar) throws JFException {
		// TODO Auto-generated method stub
	    
		if(!instrument.equals(Instrument.EURUSD))
			return;
		
		if(!period.equals(globalPeriod))
			return;
		
		signal = new DashboardSignal(instrument, period,10);
		int sign = signal.Signal(bidBar, indicators);
		
		
		if(sign != -1){
			signal.CalculateFan();
			//console.getOut().println("Buy/Sell = " + sign);
			String[] str = signal.getFanOrder();
			/*double[] db = signal.getFanOrderValues();
			
			console.getOut().println("4 = " + str[4] + "___vals = " + db[4]);
			console.getOut().println("3 = " + str[3] + "___vals = " + db[3]);
			console.getOut().println("2 = " + str[2] + "___vals = " + db[2]);
			console.getOut().println("1 = " + str[1] + "___vals = " + db[1]);
			console.getOut().println("0 = " + str[0] + "___vals = " + db[0]);*/
		}
	}

	@Override
	public void onMessage(IMessage message) throws JFException {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void onAccount(IAccount account) throws JFException {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void onStop() throws JFException {
		// TODO Auto-generated method stub
		
	}

}
